package com.yida.gwj.expend.outside.controller;

import com.yida.common.core.constant.SecurityConstants;
import com.yida.common.core.domain.R;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.system.api.RemoteUserOutsideOfficerService;
import com.yida.system.api.domain.SysUserCommunity;
import com.yida.system.api.domain.request.BindCommunityRequest;
import com.yida.system.api.domain.request.RegisterBindRequest;
import com.yida.system.api.domain.request.SysUserOutsideOfficerRemoveRequest;
import com.yida.system.api.domain.request.SysUserQueryRequest;
import com.yida.system.api.vo.OfficerUserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Description 外网用户绑定管理
 * @Author wws
 * @Date 2023-06-17
 */
@RestController
@RequestMapping("/user/outside/officer")
@Api(tags = "外网用户绑定管理")
public class SystemUserOutsideOfficerController {

    @Resource
    private RemoteUserOutsideOfficerService removeOutsideUserService;

    
    @ApiOperation(value = "内部获取用户列表",response = OfficerUserVO.class)
    @GetMapping("/list")
    public TableDataInfo innerList(SysUserQueryRequest request) {
        return removeOutsideUserService.innerList(request, SecurityConstants.INNER).getData();
    }

    
    @ApiOperation("内部绑定项目")
    @PostMapping("/bindCommunity")
    public AjaxResult innerBindCommunity(@RequestBody @Valid BindCommunityRequest request) {
        removeOutsideUserService.innerBindCommunity(request, SecurityConstants.INNER);
        return AjaxResult.success();
    }

    
    @ApiOperation(value = "内部查询已绑定项目",response = SysUserCommunity.class)
    @GetMapping("/listCommunities/{userId}")
    public  AjaxResult innerGetBindCommunities(@PathVariable("userId") Long userId) {
        return AjaxResult.success(removeOutsideUserService.innerGetBindCommunities(userId,SecurityConstants.INNER));
    }

    
    @ApiOperation("内部注册用户并绑定项目")
    @PostMapping("/registerBind")
    public AjaxResult innerRegisterAndBind(@RequestBody RegisterBindRequest request) {
        removeOutsideUserService.innerRegisterAndBind(request,SecurityConstants.INNER);
        return AjaxResult.success();
    }

    
    @ApiOperation("内部删除用户")
    @PostMapping("/removeOutsideUser")
    public AjaxResult innerRemoveOutsideUser(@RequestBody @Validated SysUserOutsideOfficerRemoveRequest request){
        removeOutsideUserService.innerRemoveOutsideUser(request,SecurityConstants.INNER);
        return AjaxResult.success();
    }
}
